$().ready(function(){
    //显示项目
    let item_var = getSearch('item');
    //显示小项
    let list = getSearch('list');
    let navItem = {};
    //大项内容
    for(let i in navList){
        if(item_var == navList[i].id){
            navItem = navList[i];
            $('.page-link li').removeClass('active');
            let lisText = [];
            $('.page-link a').each(function(index,val){
                lisText.push($(this).text());
            })
            for(let h in lisText){
                if(lisText[h]==navList[i].name){
                    // console.log(lisText[h])
                    $('.page-link li').eq(h).addClass('active');
                }
            }
            $('#big-title span').text(navList[i].sub_name);
            $('#en-title').text(navList[i].en);

        }
    }
    //小项隐藏
    $('.content').css('display','none');
    //显示主体内容
    $('.show-box').css('display','none');
    $('.show-box').each(function(){
        if($(this).data('id')==item_var){
            $(this).css('display','block');
        }
    })
    function showSItem(index){
        //小项隐藏
        $('.content').css('display','none');
        $('.content').each(function(){
            if($(this).data('index') == index){
                $(this).css('display','block')
            }
        })
    }
    let htmlNav = ''
    for(let j in navItem.list){
        if(j == list){
            htmlNav += '<li class="active"><a>'+navItem.list[j].name+'</a></li>'
            $('#low-name span').text(navItem.list[j].sub_name);
            showSItem(j)
        }else{
            htmlNav += '<li><a>'+navItem.list[j].name+'</a></li>'
        }
    }
    $('.nav-item li').eq(list).addClass('active');
    $('.nav-item').html(htmlNav);
    $('.nav-item').on('click','li',function(){
        let index = $(this).index();
        $('#low-name span').text(navItem.list[index].sub_name)
        $('.nav-item li').removeClass('active');
        $(this).addClass('active');
        showSItem(index);
    })
    if(item_var == 1){
        getIndustry();
        getSpeech();
        getLeadershipTeam();
        getCulture();
        getHonor();
    }else if(item_var == 2){
        layoutClass();
    }else if(item_var == 3){
        getTech();
        getTeam(1,function(html){
            $('#yfzj').html(html);
        })
        getTeam(2,function(html){
            $('#ylzj').html(html);
        })
        getTeam(3,function(html){
            $('#cytd').html(html);
        })
        getCy();
    }else if(item_var == 5){
        getChinaRun();
        lunTan();
    }
})
//获取产业介绍
function getIndustry(){
    getAjax('/Api/New/get_jtjs',function(res){
        $('#chanyejieshao').html(res[0].content);
    })
}
//获取总裁寄语
function getSpeech(){
    getAjax('/Api/New/get_dszzc',function(res){
        // console.log(res);
        $('#speech').html(res[0].content);
    })
}
//领导团队
function getLeadershipTeam(){
    getAjax('/Api/New/get_ldtd',function(res){
        // console.log(res);
        let html = '';
        for(let i in res){
            html += '<li>';
            html += '<div class="personal-photo" style="background: url('+res[i].img+') no-repeat center center/cover"></div>';
            html += '<div class="personal-info">';
            html += '<p class="personal-name">'+res[i].title+'<span class="personal-post">'+res[i].title1+'</span></p>';
            html += '<div class="personal-desc">'+res[i].content+'</div>';
            html += '</div>';
            html += '</li>';
        }
        $('#leadership-team').html(html);
    })
}
//获取企业文化
function getCulture(){
    getAjax('/Api/New/get_qywh',function(res){
        // console.log(res);
        $('#culture').html(res[0].content);
    })
}
//获取集团荣誉
function getHonor(){
    getAjax('/Api/New/get_jtry',function(res){
        console.log(res);
        let html = '';
        for(let i in res){
            html += '<li>';
            html += '<div class="honor-img"><img src="'+res[i].img+'" alt="'+res[i].title+'"></div>';
            html += '<div class="honor-info">'+res[i].content+'</div>';
            html += '</li>';
        }
        $('#honor-list').html(html);
    })
}
//获取产业布局
function layoutClass(){
    getAjax('/Api/New/get_tfncybj',function(res){
        let $layout = $('.show-box[data-id=2]');
        let $content = $layout.find('.content');
        $content.each(function(){
            // console.log($(this).attr('data-id'));
            for(let i in res){
                if(res[i].id == $(this).attr('data-id')){
                    $(this).html(res[i].content);
                }
            }
        })
    })
}
//获取科研机构
function getTech(){
    getAjax('/Api/New/get_yfpt',function(res){
        // console.log(res);
        let html = '';
        for(let i in res){
            // html += '<li><div class="office-top">';
            // html += '<div class="office-img"><img src="'+res[i].img+'" alt="'+res[i].title+'" ></div>';
            // html += '<p class="office-name">'+res[i].title+'</p></div>';
            // html += '<div class="office-bottom">';
            // html += '<p class="office-function">'+res[i].sub_content+'</p>';
            // html += '<p class="office-info">'+res[i].content+'</p>';
            // html += '</div></li>';
            html += '<li>';
            html += '<div class="office-l"><img src="'+res[i].img+'" alt=""></div>';
            html += '<div class="office-r">';
            html += '<p class="office-name">'+res[i].title+'</p>';
            html += '<p class="office-function">'+res[i].sub_content+'</p>';
            html += '<p class="office-desc">'+res[i].content+'</p>';
            html += '</div>';
            html += '</li>'



        }
        $('#kyjg').html(html);
    })
}
//获取专家 团队
function getTeam(type,func){
    getAjax('/Api/New/get_ptzj',function(res){
        let html = '';
        for(let i in res){
            html += ' <li>';
            html += ' <div class="expert-img"><img src="'+res[i].img+'" alt=""></div>';
            html += '<div class="expert-info"><p class="expert-name">'+res[i].title+'</p>';
            html += '<div class="expert-desc">'+res[i].content+'</div>';
            html += ' </li>'
        }
        func(html);
    },{
        type:type
    })
}
//获取产研基地
function getCy(){
    getAjax('/Api/New/get_cyjd',function(res){
        // console.log(res);
        $('#cyjd').html(res[0].content);
    })
}
//获取健康中国行
function getChinaRun(){
    getAjax('/Api/New/jkzg',function(res){
        // console.log(res);
        $('#china-run').html(res.content);
    })
}
//获取高峰论坛
function lunTan(){
    getAjax('/Api/New/gflt',function(res){
        console.log(res);
        $('#luntan').html(res.content);

    })
}
